import 'package:flutter/material.dart';

class BottomView extends StatefulWidget {
  ValueChanged bottomSelectCallBack;
  var pageIndex;

  BottomView(this.bottomSelectCallBack, this.pageIndex);

  @override
  _BottomViewState createState() => _BottomViewState();
}

class _BottomViewState extends State<BottomView> {
  @override
  Widget build(BuildContext context) {
    //屏幕宽度
    var width = MediaQuery.of(context).size.width;
    return Container(
      padding: EdgeInsets.only(top: 5),
      width: width,
      height: 50,
      color: Colors.white,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        children: <Widget>[
          InkWell(
            onTap: () {
              widget.pageIndex = 0;
              widget.bottomSelectCallBack(0);
              setState(() {});
            },
            child: Column(
              children: <Widget>[
                Icon(Icons.home,
                    color: widget.pageIndex == 0
                        ? Colors.redAccent
                        : Colors.black),
                Text(
                  "首页",
                  style: TextStyle(
                      color: widget.pageIndex == 0
                          ? Colors.redAccent
                          : Colors.black),
                ),
              ],
            ),
          ),
          InkWell(
            onTap: () {
              widget.pageIndex = 1;
              widget.bottomSelectCallBack(1);
              setState(() {});
            },
            child: Column(
              children: <Widget>[
                Icon(Icons.tv,
                    color: widget.pageIndex == 1
                        ? Colors.redAccent
                        : Colors.black),
                Text(
                  "频道",
                  style: TextStyle(
                      color: widget.pageIndex == 1
                          ? Colors.redAccent
                          : Colors.black),
                ),
              ],
            ),
          ),
          InkWell(
            onTap: () {
              widget.pageIndex = 2;
              widget.bottomSelectCallBack(2);
              setState(() {});
            },
            child: Column(
              children: <Widget>[
                Icon(Icons.move_to_inbox,
                    color: widget.pageIndex == 2
                        ? Colors.redAccent
                        : Colors.black),
                Text(
                  "动态",
                  style: TextStyle(
                      color: widget.pageIndex == 2
                          ? Colors.redAccent
                          : Colors.black),
                ),
              ],
            ),
          ),
          InkWell(
            onTap: () {
              widget.pageIndex = 3;
              widget.bottomSelectCallBack(3);
              setState(() {});
            },
            child: Column(
              children: <Widget>[
                Icon(Icons.shop,
                    color: widget.pageIndex == 3
                        ? Colors.redAccent
                        : Colors.black),
                Text(
                  "会员购",
                  style: TextStyle(
                      color: widget.pageIndex == 3
                          ? Colors.redAccent
                          : Colors.black),
                ),
              ],
            ),
          )
        ],
      ),
    );
  }
}
